<?php
if (!defined('IN_CONTEXT')) die('access violation error!');

$stack = array();
//if(!empty($templates[0]))
//{
?>
<style type="text/css">
table td {
	text-align:left;
}
</style>
<table style="margin-top:20px;" width="100%" border="0" cellpadding="2" cellspacing="0" bordercolor="#4c4c4c">
<tr>
<td class="table_title" width="5%">序号</td>
<td class="table_title" width="10%">模板名</td>
<td class="table_title" width="14%">模板行业</td>
<td class="table_title" width="14%">三级域名</td>
<td class="table_title" width="8%">总监人员</td>
<td class="table_title" width="9%">设计人员</td>
<td class="table_title" width="8%">测试组长</td>
<td class="table_title" width="9%">测试人员</td>
<td class="table_title" width="8%">发布人员</td>
<td class="table_title" width="10%">状态</td>
<td class="table_title" width="5%">操作</td>
</tr>
<?php 
$i = 1;
foreach($templates as $v)
{
	if(empty($v)) continue;
	foreach($v as $k1 => $v1)
	{
		if(in_array($v1['tpl_id'], $stack)) continue;//不允许显示重复记录
		$stack[] = $v1['tpl_id'];
		
		$template_category_name = $template_categories[$v1['tpl_category_id']];
		$master_name = $users[$v1['tpl_master_id']];
		$designer_name = $users[$v1['tpl_designer_id']];
		$tester_leader_name = $users[$v1['tpl_tester_leader_id']];
		$tester_name = $users[$v1['tpl_tester_id']];
		$publisher_name = empty($users[$v1['tpl_publisher_id']]) ? '-' : $users[$v1['tpl_publisher_id']];
		
		if($v1['tpl_status'] == 6)
		{
			$status = '设计审核通过';	
		}
		elseif($v1['tpl_status'] == 8)
		{
			$status = '发布完成';	
		}
		elseif($v1['tpl_status'] == 9)
		{
			$status = '流程撤销';	
		}
		$tpl_domain = empty($v1['tpl_domain']) ? '-' : $v1['tpl_domain'];
		if(!(strpos($tpl_domain, 'http') === false))
		{
			$length = strlen($tpl_domain) - 7;
			$tpl_domain = substr($tpl_domain,-1 * $length,$length); 
		}
		echo "<tr><td>$i</td><td>{$v1['tpl_name']}</td><td>$template_category_name</td><td><a target='_blank' href='http://$tpl_domain'>$tpl_domain</a></td><td>$master_name</td><td>$designer_name</td><td>$tester_leader_name</td><td>$tester_name</td><td>$publisher_name</td><td>$status</td><td><a title='查看' href='index.php?_m=job&_a=viewJobPage&tpl_id={$v1['tpl_id']}'><img style='border:none;' src='./images/view.gif'/></a></td></tr>";
		$i++;
	}
}
?>
</table>
<?php
//}
//else
//{
//	echo "<p style='font-size:12px;margin-top:20px;'>Data is empty</p>";
//}
?>
